package com.balabala.gym_system.controller.admin;


import com.balabala.goods.pojo.dto.BookCourseQueryDto;
import com.balabala.gym_system.pojo.dto.ReservationListDto;
import com.balabala.gym_system.pojo.entity.ReservationList;
import com.balabala.gym_system.pojo.vo.ReservationVo;
import com.balabala.gym_system.service.ReservationListService;
import com.balabala.result.Result;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@Api(tags = "预约信息接口")
@RequestMapping("/admin/ReservationList")
@CrossOrigin
public class ReservationListController {

    @Autowired
    private ReservationListService reservationListService;

    //根据条件列表查询
    @PostMapping("/findList")
    @ApiOperation(value = "预约课程信息列表")
    public Result findListByQueryDto(BookCourseQueryDto bookCourseQueryDto){

        //
        log.info("传递的参数:{}",bookCourseQueryDto.getCoachId(),bookCourseQueryDto.getLimit(),bookCourseQueryDto.getPage());

        //1.组装分页条件
        PageHelper.startPage(bookCourseQueryDto.getPage(),bookCourseQueryDto.getLimit());

        List<ReservationVo> reservationList = reservationListService.findByQueryDto(bookCourseQueryDto);
        PageInfo<ReservationVo> pageInfo=new PageInfo<>(reservationList);

        //远程调用教练，场馆，场地
        return Result.ok(pageInfo.getList(),pageInfo.getTotal());

    }

    //根据id删除预约课程表
     @GetMapping("/deleteById")
     @ApiOperation(value = "删除预约课程信息")
     public Result deleteById(@RequestParam Long id){
        reservationListService.deleteReservation(id);
        return Result.ok();
     }


}
